<template>
  <el-form label-width="120px" ref="formRef" :model="form" :rules="formRules">
    <el-row>
      <el-col :span="12">
        <el-form-item label="角色标识" prop="code">
          <el-input disabled clearable placeholder="请输入角色标识" v-model="form.code"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="角色名称" prop="name">
          <el-input clearable placeholder="请输入角色名称" v-model="form.name"></el-input>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row>
      <el-col :span="12">
        <el-form-item label="是否启用" prop="enabled">
          <el-radio-group disabled v-model="form.enabled">
            <el-radio-button :value="true" border>启用</el-radio-button>
            <el-radio-button :value="false" border>停用</el-radio-button>
          </el-radio-group>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="排序" prop="sort">
          <el-input-number disabled v-model="form.sort" :min="1" controls-position="right" size="large"
                           placeholder="请输入排序"></el-input-number>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row>
      <el-col :span="24">
        <el-form-item label="备注" prop="remark">
          <el-input type="textarea" v-model="form.remark" clearable placeholder="请输入备注"></el-input>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>

<script setup lang="js">
import {reactive, ref} from "vue";

const props = defineProps({
  form: {
    type: Object,
    default: {}
  }
})
const formRef = ref();
const categoryProps = {
  label: (data) => data.name + "-" + data.code,
  children: 'children',
}
const formRules = reactive({
  code: [{required: true, message: "角色标识为必填项", trigger: "blur"}],
  name: [{required: true, message: "角色名称为必填项", trigger: "blur"}],
  menuIdList: [{required: true, message: "菜单权限列表为必填项", trigger: "blur"}],
  enabled: [{required: true, message: "是否启用为必填项", trigger: "blur"}],
  sort: [{required: true, message: "排序为必填项", trigger: "blur"}],
});
const getFormRef = () => {
  return formRef.value;
}

defineExpose({getFormRef});
</script>
